package jparchess.command;

import java.awt.Dimension;

import jparchess.engine.Board;
import jparchess.engine.D;
import jparchess.engine.Evaluator;
import jparchess.engine.GameLine;
import jparchess.engine.MoveGenerator;
import jparchess.engine.MoveMaker;
import jparchess.engine.Search;
import jparchess.gui.BoardGUI;

public class Game {
	public Board board;
	public Search search;
	public GameLine gameLine;
	public BoardGUI boardGUI;
	
	public void start() {
		board = new Board();
		gameLine = new GameLine();
		search = new Search(board, gameLine);

		board.sideToMove = D.WHITE_TO_MOVE;
		//search.negamax(2, -9999, 9999);
		
		int searchDepth = 4;
		for (int i = 1; i<=searchDepth; i++) {
			System.out.println(i + " -depth : " + search.perft(0, i));			
		}
		
		System.out.println("Captures : " + search.perftCaptures);
		System.out.println("Checks : " + search.perftCastling);
		System.out.println("Castling : " + search.perftChecks);
		
		
		// reinit
		board = new Board();
		gameLine = new GameLine();
		search = new Search(board, gameLine);

		board.sideToMove = D.WHITE_TO_MOVE;
		search.searchDepth = 5;
		
		// gui
		boardGUI = new BoardGUI(this);
		boardGUI.initBoard();
		boardGUI.setSize(new Dimension(1100,800));
		boardGUI.setVisible(true);
		boardGUI.updateBoard();
		boardGUI.updateView(false, 0);
		
	}

	public void terminate() {
		boardGUI.dispose();
	}
}
